﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VFDDriver.VFD;

namespace VFDEmulator
{
    public partial class Char : UserControl
    {

        private byte _value;
        /// <summary>TODO: Add description here.</summary>
        public byte Value
        {
            get { return _value; }
            set
            {
                _value = value;
                byte[] bytes = null;
                if (CharMemory.Instance.Memory.ContainsKey(value))
                {
                    bytes = CharMemory.Instance.Memory[value];

                    string val = System.Convert.ToString(bytes[0], 2).PadLeft(8, '0');
                    point11.State = val[0] == '1';
                    point12.State = val[1] == '1';
                    point13.State = val[2] == '1';
                    point14.State = val[3] == '1';
                    point15.State = val[4] == '1';

                    val = System.Convert.ToString(bytes[1], 2).PadLeft(8, '0');
                    point21.State = val[0] == '1';
                    point22.State = val[1] == '1';
                    point23.State = val[2] == '1';
                    point24.State = val[3] == '1';
                    point25.State = val[4] == '1';

                    val = System.Convert.ToString(bytes[2], 2).PadLeft(8, '0');
                    point31.State = val[0] == '1';
                    point32.State = val[1] == '1';
                    point33.State = val[2] == '1';
                    point34.State = val[3] == '1';
                    point35.State = val[4] == '1';

                    val = System.Convert.ToString(bytes[3], 2).PadLeft(8, '0');
                    point41.State = val[0] == '1';
                    point42.State = val[1] == '1';
                    point43.State = val[2] == '1';
                    point44.State = val[3] == '1';
                    point45.State = val[4] == '1';

                    val = System.Convert.ToString(bytes[4], 2).PadLeft(8, '0');
                    point51.State = val[0] == '1';
                    point52.State = val[1] == '1';
                    point53.State = val[2] == '1';
                    point54.State = val[3] == '1';
                    point55.State = val[4] == '1';

                    val = System.Convert.ToString(bytes[5], 2).PadLeft(8, '0');
                    point61.State = val[0] == '1';
                    point62.State = val[1] == '1';
                    point63.State = val[2] == '1';
                    point64.State = val[3] == '1';
                    point65.State = val[4] == '1';

                    val = System.Convert.ToString(bytes[6], 2).PadLeft(8, '0');
                    point71.State = val[0] == '1';
                    point72.State = val[1] == '1';
                    point73.State = val[2] == '1';
                    point74.State = val[3] == '1';
                    point75.State = val[4] == '1';

                }
                else
                {
                    point11.State = false;
                    point12.State = false;
                    point13.State = false;
                    point14.State = false;
                    point15.State = false;

                    point21.State = false;
                    point22.State = false;
                    point23.State = false;
                    point24.State = false;
                    point25.State = false;

                    point31.State = false;
                    point32.State = false;
                    point33.State = false;
                    point34.State = false;
                    point35.State = false;

                    point41.State = false;
                    point42.State = false;
                    point43.State = false;
                    point44.State = false;
                    point45.State = false;

                    point51.State = false;
                    point52.State = false;
                    point53.State = false;
                    point54.State = false;
                    point55.State = false;

                    point61.State = false;
                    point62.State = false;
                    point63.State = false;
                    point64.State = false;
                    point65.State = false;

                    point71.State = false;
                    point72.State = false;
                    point73.State = false;
                    point74.State = false;
                    point75.State = false;
                }

                
            }
        }

        public Char()
        {
            InitializeComponent();
        }
    }
}
